<?php

/**
 * Contacto form base class.
 *
 * @method Contacto getObject() Returns the current form's model object
 *
 * @package    SAC_CLonsa
 * @subpackage form
 * @author     Your name here
 */
abstract class BaseContactoForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'            => new sfWidgetFormInputHidden(),
      'nombre'        => new sfWidgetFormInputText(),
      'observaciones' => new sfWidgetFormTextarea(),
      'rut'           => new sfWidgetFormInputText(),
      'proveedor_id'  => new sfWidgetFormPropelChoice(array('model' => 'Proveedor', 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id'            => new sfValidatorPropelChoice(array('model' => 'Contacto', 'column' => 'id', 'required' => false)),
      'nombre'        => new sfValidatorString(array('max_length' => 40)),
      'observaciones' => new sfValidatorString(array('required' => false)),
      'rut'           => new sfValidatorString(array('max_length' => 14, 'required' => false)),
      'proveedor_id'  => new sfValidatorPropelChoice(array('model' => 'Proveedor', 'column' => 'id')),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorPropelUnique(array('model' => 'Contacto', 'column' => array('nombre'))),
        new sfValidatorPropelUnique(array('model' => 'Contacto', 'column' => array('rut'))),
      ))
    );

    $this->widgetSchema->setNameFormat('contacto[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Contacto';
  }


}
